package coco.component
{
    import flash.events.MouseEvent;
    
    import mx.core.IInvalidating;
    import mx.core.mx_internal;
    
    import spark.components.VScrollBar;
    import spark.core.IViewport;
    import spark.core.NavigationUnit;
    
    use namespace mx_internal;
    
    public class CocoVScrollBar extends VScrollBar
    {
        override mx_internal function mouseWheelHandler(event:MouseEvent):void
        {
			const vp:IViewport = viewport;
			if (event.isDefaultPrevented() || !vp || !vp.visible)
				return;
			
			var nSteps:uint = Math.abs(event.delta);
			var navigationUnit:uint;
			
			// Scroll event.delta "steps".  
			
			navigationUnit = (event.delta < 0) ? NavigationUnit.DOWN : NavigationUnit.UP;
			var vspDelta:Number = vp.getVerticalScrollPositionDelta(navigationUnit);
			if (!isNaN(vspDelta))
			{
				vp.verticalScrollPosition += vspDelta;
				if (vp is IInvalidating)
					IInvalidating(vp).validateNow();
			}
			
			event.preventDefault();
        }

    }
}